package com.huawei.esdk.uc.base;

import java.util.HashMap;
import java.util.Map;

import com.huawei.esdk.platform.callback.itf.ICallback;
import com.huawei.esdk.platform.common.bean.callback.CallbackMessage;

public class UCNotifyCallback implements ICallback
{
    private static final Map<String, ICallback> MODULE_CALLBACKS = new HashMap<String, ICallback>();
    
    @Override
    public Object onNotifyMsg(CallbackMessage callbackMessage)
    {
        ICallback moduleCallback = MODULE_CALLBACKS.get(callbackMessage.getCallbackItfInfo().getModule());
        if (null != moduleCallback)
        {
            return moduleCallback.onNotifyMsg(callbackMessage);
        }
        
        return null;
    }
    
    public void registerCallback(String module, ICallback callback)
    {
        MODULE_CALLBACKS.put(module, callback);
    }
    
    public void unregisterCallback(String module)
    {
        MODULE_CALLBACKS.remove(module);
    }
    
    public boolean hasRegisteredModule()
    {
        return !MODULE_CALLBACKS.isEmpty();
    }
}
